
*=====================================
* Variance decomposition instrument
*=====================================

clear

use "/Users/sv5011/Desktop/Work/Papers/Working papers/6_Do Conflict Traps Exist? Natural experimental evidence from riots in India (with Goyal)/Ethnic riots extended data/Final ethnic riots data.dta"

tsset dist year

xtsum fridayfestival

display .0617785/.499581
// .12366063
// 12.4% of variance is cross-sectional
// 87.6% of variance is over time

*=====================================
* Balance test
*=====================================

clear

use "/Users/sv5011/Desktop/Work/Papers/Working papers/6_Do Conflict Traps Exist? Natural experimental evidence from riots in India (with Goyal)/Ethnic riots extended data/Final ethnic riots data.dta"

tsset dist year

gen dummy_1950_1955 = 0 
replace dummy_1950_1955 = 1 if year<1956 &year>1950

gen dummy_1956_1961 = 0 
replace dummy_1956_1961 = 1 if year>1955 & year<1962

gen dummy_1961_1965 = 0 
replace dummy_1961_1965 = 1 if year>1961 & year<1966

gen dummy_1966_1971 = 0 
replace dummy_1966_1971 = 1 if year>1965 & year<1972

gen dummy_1971_1975 = 0 
replace dummy_1971_1975 = 1 if year>1971 & year<1976

gen dummy_1976_1980 = 0 
replace dummy_1976_1980 = 1 if year>1975 & year<1981

gen dummy_1981_1985 = 0 
replace dummy_1981_1985 = 1 if year>1980 & year<1986

gen dummy_1986_1991 = 0 
replace dummy_1986_1991 = 1 if year>1985 & year<1992

gen dummy_1991_1995 = 0
replace dummy_1991_1995 = 1 if year>1991 & year<1996

gen dummy_1996_2001 = 0 
replace dummy_1996_2001 = 1 if year>1995 & year<2002

gen dummy_2001_2006 = 0 
replace dummy_2001_2006 = 1 if year>2001


** Column 1 -- Riot
quietly: xtscc riot fridayfestival dummy_1956_1961 dummy_1961_1965 dummy_1966_1971 dummy_1971_1975 dummy_1976_1980 dummy_1981_1985 dummy_1986_1991 dummy_1991_1995 dummy_1996_2001 dummy_2001_2006, fe lag(56)
quietly: estimates store m1, title(Riot)

** Column 2 -- % of muslims
quietly: xtscc muslim_pop fridayfestival dummy_1956_1961 dummy_1961_1965 dummy_1966_1971 dummy_1971_1975 dummy_1976_1980 dummy_1981_1985 dummy_1986_1991 dummy_1991_1995 dummy_1996_2001 dummy_2001_2006, fe lag(24)
quietly: estimates store m2, title(Muslims)

** Column 3 -- Urbanization
quietly: xtscc urban_pop fridayfestival dummy_1956_1961 dummy_1961_1965 dummy_1966_1971 dummy_1971_1975 dummy_1976_1980 dummy_1981_1985 dummy_1986_1991 dummy_1991_1995 dummy_1996_2001 dummy_2001_2006, fe lag(24)
quietly: estimates store m3, title(Urbanization)

** Column 4 -- % literature
quietly: xtscc perc_literate fridayfestival dummy_1956_1961 dummy_1961_1965 dummy_1966_1971 dummy_1971_1975 dummy_1976_1980 dummy_1981_1985 dummy_1986_1991 dummy_1991_1995 dummy_1996_2001 dummy_2001_2006, fe lag(24)
quietly: estimates store m4, title(Literacy)

** Column 5 -- % electricity
quietly: xtscc perc_electricity fridayfestival dummy_1956_1961 dummy_1961_1965 dummy_1966_1971 dummy_1971_1975 dummy_1976_1980 dummy_1981_1985 dummy_1986_1991 dummy_1991_1995 dummy_1996_2001 dummy_2001_2006, fe lag(24)
quietly: estimates store m5, title(Electricity)


cd "/Users/samvannoort/Desktop/Work/Papers/Working papers/9_Do Conflict Traps Exist? Natural experimental evidence from riots in India (with Goyal)/output"
estout m1 m2 m3 m4 m5 using "balance_test.tex", replace style(tex) ///
varlabels(fridayfestival "Friday festival $ _{t-1}$") ///
 cells(b(star fmt(3)) se(par fmt(3))) legend label stats(N N_g, fmt(%7.0f %7.0f)) keep(fridayfestival *cons*)
 

*=====================================
*	Main results
*=====================================

clear

use "/Users/sv5011/Desktop/Work/Papers/Working papers/6_Do Conflict Traps Exist? Natural experimental evidence from riots in India (with Goyal)/Ethnic riots extended data/Final ethnic riots data.dta"

tsset dist year

gen dummy_1950_1955 = 0 
replace dummy_1950_1955 = 1 if year<1956 &year>1950

gen dummy_1956_1961 = 0 
replace dummy_1956_1961 = 1 if year>1955 & year<1962

gen dummy_1961_1965 = 0 
replace dummy_1961_1965 = 1 if year>1961 & year<1966

gen dummy_1966_1971 = 0 
replace dummy_1966_1971 = 1 if year>1965 & year<1972

gen dummy_1971_1975 = 0 
replace dummy_1971_1975 = 1 if year>1971 & year<1976

gen dummy_1976_1980 = 0 
replace dummy_1976_1980 = 1 if year>1975 & year<1981

gen dummy_1981_1985 = 0 
replace dummy_1981_1985 = 1 if year>1980 & year<1986

gen dummy_1986_1991 = 0 
replace dummy_1986_1991 = 1 if year>1985 & year<1992

gen dummy_1991_1995 = 0
replace dummy_1991_1995 = 1 if year>1991 & year<1996

gen dummy_1996_2001 = 0 
replace dummy_1996_2001 = 1 if year>1995 & year<2002

gen dummy_2001_2006 = 0 
replace dummy_2001_2006 = 1 if year>2001

estimates clear 

** Column 1 -- Riot, fixed effects
quietly: xtscc riot l.riot dummy_1956_1961 dummy_1961_1965 dummy_1966_1971 dummy_1971_1975 dummy_1976_1980 dummy_1981_1985 dummy_1986_1991 dummy_1991_1995 dummy_1996_2001 dummy_2001_2006, fe lag(55)
quietly: estimates store m1, title(OLS)

** Column 2 -- Riot, 2sls
quietly: xi: ivreg2 riot (l.riot = l.fridayfestival) i.dist dummy_1956_1961 dummy_1961_1965 dummy_1966_1971 dummy_1971_1975 dummy_1976_1980 dummy_1981_1985 dummy_1986_1991 dummy_1991_1995 dummy_1996_2001 dummy_2001_2006, first dkraay(55) savefirst savefprefix(first1)
quietly: estimates store m2, title(2SLS)

** Column 3 -- Riot, reduced form
quietly: xtscc riot l.fridayfestival dummy_1956_1961 dummy_1961_1965 dummy_1966_1971 dummy_1971_1975 dummy_1976_1980 dummy_1981_1985 dummy_1986_1991 dummy_1991_1995 dummy_1996_2001 dummy_2001_2006, fe lag(55)
quietly: estimates store m3, title(Reduced form)


 cd "/Users/samvannoort/Desktop/Work/Papers/Working papers/9_Do Conflict Traps Exist? Natural experimental evidence from riots in India (with Goyal)/output"
estout m1 first1* m2 m3 using "main_results.tex", replace style(tex) ///
varlabels(L.riot "Riot $ _{t-1}$" L.fridayfestival "Friday festival $ _{t-1}$") ///
 cells(b(star fmt(3)) se(par fmt(3))) legend label stats(widstat N N_g, fmt(%7.1f %7.0f %7.0f)) keep(*riot* *fes*)
 

*=====================================
*	Robustness checks
*=====================================

estimates clear 
clear
use "/Users/sv5011/Desktop/Work/Papers/Working papers/6_Do Conflict Traps Exist? Natural experimental evidence from riots in India (with Goyal)/Ethnic riots extended data/Final ethnic riots data.dta"

tsset dist year


gen dummy_1950_1955 = 0 
replace dummy_1950_1955 = 1 if year<1956 &year>1950

gen dummy_1956_1961 = 0 
replace dummy_1956_1961 = 1 if year>1955 & year<1962

gen dummy_1961_1965 = 0 
replace dummy_1961_1965 = 1 if year>1961 & year<1966

gen dummy_1966_1971 = 0 
replace dummy_1966_1971 = 1 if year>1965 & year<1972

gen dummy_1971_1975 = 0 
replace dummy_1971_1975 = 1 if year>1971 & year<1976

gen dummy_1976_1980 = 0 
replace dummy_1976_1980 = 1 if year>1975 & year<1981

gen dummy_1981_1985 = 0 
replace dummy_1981_1985 = 1 if year>1980 & year<1986

gen dummy_1986_1991 = 0 
replace dummy_1986_1991 = 1 if year>1985 & year<1992

gen dummy_1991_1995 = 0
replace dummy_1991_1995 = 1 if year>1991 & year<1996

gen dummy_1996_2001 = 0 
replace dummy_1996_2001 = 1 if year>1995 & year<2002

gen dummy_2001_2006 = 0 
replace dummy_2001_2006 = 1 if year>2001

** Column 1 -- Baseline
quietly: xtscc riot l.fridayfestival dummy_1956_1961 dummy_1961_1965 dummy_1966_1971 dummy_1971_1975 dummy_1976_1980 dummy_1981_1985 dummy_1986_1991 dummy_1991_1995 dummy_1996_2001 dummy_2001_2006, fe lag(20)
quietly: estimates store m1_riot, title(Baseline)

quietly: xtscc nriot l.fridayfestival dummy_1956_1961 dummy_1961_1965 dummy_1966_1971 dummy_1971_1975 dummy_1976_1980 dummy_1981_1985 dummy_1986_1991 dummy_1991_1995 dummy_1996_2001 dummy_2001_2006, fe lag(20)
quietly: estimates store m1_nriot, title(Baseline)

quietly: xtscc riotnear100 l.fridayfestival dummy_1956_1961 dummy_1961_1965 dummy_1966_1971 dummy_1971_1975 dummy_1976_1980 dummy_1981_1985 dummy_1986_1991 dummy_1991_1995 dummy_1996_2001 dummy_2001_2006, fe lag(20)
quietly: estimates store m1_riotnear100, title(Baseline)


** Column 2 -- Add control variables
gen l1_muslim = l.muslim_pop
gen l1_urb = l.urban_pop
gen l1_lit = l.perc_literate
gen l1_ele = l.perc_electricity
 
quietly: xtscc riot l.fridayfestival l1_muslim l1_urb l1_lit l1_ele dummy_1956_1961 dummy_1961_1965 dummy_1966_1971 dummy_1971_1975 dummy_1976_1980 dummy_1981_1985 dummy_1986_1991 dummy_1991_1995 dummy_1996_2001 dummy_2001_2006, fe lag(14)
quietly: estimates store m2_riot, title(Controls)

quietly: xtscc nriot l.fridayfestival l1_muslim l1_urb l1_lit l1_ele dummy_1956_1961 dummy_1961_1965 dummy_1966_1971 dummy_1971_1975 dummy_1976_1980 dummy_1981_1985 dummy_1986_1991 dummy_1991_1995 dummy_1996_2001 dummy_2001_2006, fe lag(14)
quietly: estimates store m2_nriot, title(Controls)

quietly: xtscc riotnear100 l.fridayfestival l1_muslim l1_urb l1_lit l1_ele dummy_1956_1961 dummy_1961_1965 dummy_1966_1971 dummy_1971_1975 dummy_1976_1980 dummy_1981_1985 dummy_1986_1991 dummy_1991_1995 dummy_1996_2001 dummy_2001_2006, fe lag(14)
quietly: estimates store m2_riotnear100, title(Controls)

** Column 3 - Drop if No. of riots > 2
gen outlier = 0
replace outlier = 1 if nriot>2

quietly: xtscc riot l.fridayfestival dummy_1956_1961 dummy_1961_1965 dummy_1966_1971 dummy_1971_1975 dummy_1976_1980 dummy_1981_1985 dummy_1986_1991 dummy_1991_1995 dummy_1996_2001 dummy_2001_2006 if outlier==0, fe lag(20)
quietly: estimates store m3_riot, title(Outliers)

quietly: xtscc nriot l.fridayfestival dummy_1956_1961 dummy_1961_1965 dummy_1966_1971 dummy_1971_1975 dummy_1976_1980 dummy_1981_1985 dummy_1986_1991 dummy_1991_1995 dummy_1996_2001 dummy_2001_2006 if outlier==0, fe lag(20)
quietly: estimates store m3_nriot, title(Outliers)

quietly: xtscc riotnear100 l.fridayfestival dummy_1956_1961 dummy_1961_1965 dummy_1966_1971 dummy_1971_1975 dummy_1976_1980 dummy_1981_1985 dummy_1986_1991 dummy_1991_1995 dummy_1996_2001 dummy_2001_2006 if outlier==0, fe lag(20)
quietly: estimates store m3_riotnear100, title(Outliers)

** Column 4 -- Linear time trend
egen state_id = group(state)

quietly: xtscc riot l.fridayfestival dummy_1956_1961 dummy_1961_1965 dummy_1966_1971 dummy_1971_1975 dummy_1976_1980 dummy_1981_1985 dummy_1986_1991 dummy_1991_1995 dummy_1996_2001 dummy_2001_2006 i.state_id##c.year, fe lag(20)
quietly: estimates store m4_riot, title(Trend)

quietly: xtscc nriot l.fridayfestival dummy_1956_1961 dummy_1961_1965 dummy_1966_1971 dummy_1971_1975 dummy_1976_1980 dummy_1981_1985 dummy_1986_1991 dummy_1991_1995 dummy_1996_2001 dummy_2001_2006 i.state_id##c.year, fe lag(20)
quietly: estimates store m4_nriot, title(Trend)

quietly: xtscc riotnear100 l.fridayfestival dummy_1956_1961 dummy_1961_1965 dummy_1966_1971 dummy_1971_1975 dummy_1976_1980 dummy_1981_1985 dummy_1986_1991 dummy_1991_1995 dummy_1996_2001 dummy_2001_2006 i.state_id##c.year, fe lag(20)
quietly: estimates store m4_riotnear100, title(Trend)

** Column 5 -- State panel
clear
use "/Users/sv5011/Desktop/Work/Papers/Working papers/6_Do Conflict Traps Exist? Natural experimental evidence from riots in India (with Goyal)/Ethnic riots extended data/Final ethnic riots data.dta"

egen state_id = group(state)

collapse riot nriot riotnear100 fridayfestival, by(state_id year state)

tsset state_id year


gen dummy_1950_1955 = 0 
replace dummy_1950_1955 = 1 if year<1956 &year>1950

gen dummy_1956_1961 = 0 
replace dummy_1956_1961 = 1 if year>1955 & year<1962

gen dummy_1961_1965 = 0 
replace dummy_1961_1965 = 1 if year>1961 & year<1966

gen dummy_1966_1971 = 0 
replace dummy_1966_1971 = 1 if year>1965 & year<1972

gen dummy_1971_1975 = 0 
replace dummy_1971_1975 = 1 if year>1971 & year<1976

gen dummy_1976_1980 = 0 
replace dummy_1976_1980 = 1 if year>1975 & year<1981

gen dummy_1981_1985 = 0 
replace dummy_1981_1985 = 1 if year>1980 & year<1986

gen dummy_1986_1991 = 0 
replace dummy_1986_1991 = 1 if year>1985 & year<1992

gen dummy_1991_1995 = 0
replace dummy_1991_1995 = 1 if year>1991 & year<1996

gen dummy_1996_2001 = 0 
replace dummy_1996_2001 = 1 if year>1995 & year<2002

gen dummy_2001_2006 = 0 
replace dummy_2001_2006 = 1 if year>2001

gen state_riot = . if riot==.
replace state_riot = 0 if riot==0
replace state_riot = 1 if riot>0

quietly: xtscc riot l.fridayfestival dummy_1956_1961 dummy_1961_1965 dummy_1966_1971 dummy_1971_1975 dummy_1976_1980 dummy_1981_1985 dummy_1986_1991 dummy_1991_1995 dummy_1996_2001 dummy_2001_2006, fe lag(20)
quietly: estimates store m5_riot, title(State-level)

quietly: xtscc nriot l.fridayfestival dummy_1956_1961 dummy_1961_1965 dummy_1966_1971 dummy_1971_1975 dummy_1976_1980 dummy_1981_1985 dummy_1986_1991 dummy_1991_1995 dummy_1996_2001 dummy_2001_2006, fe lag(20)
quietly: estimates store m5_nriot, title(State-level)

quietly: xtscc riotnear100 l.fridayfestival dummy_1956_1961 dummy_1961_1965 dummy_1966_1971 dummy_1971_1975 dummy_1976_1980 dummy_1981_1985 dummy_1986_1991 dummy_1991_1995 dummy_1996_2001 dummy_2001_2006, fe lag(20)
quietly: estimates store m5_riotnear100, title(State-level)

 cd "/Users/samvannoort/Desktop/Work/Papers/Working papers/9_Do Conflict Traps Exist? Natural experimental evidence from riots in India (with Goyal)/output"
estout m1_riot m2_riot m3_riot m4_riot m5_riot using "robustness_riot.tex", replace style(tex) varlabels(L.fridayfestival "Friday festival $ _{t-1}$") cells(b(star fmt(3)) se(par fmt(3))) legend label stats(N N_g, fmt(%7.0f %7.0f)) keep(*fridayfestival*)

estout m1_nriot m2_nriot m3_nriot m4_nriot m5_nriot using "robustness_nriot.tex", replace style(tex) varlabels(L.fridayfestival "Friday festival $ _{t-1}$") cells(b(star fmt(3)) se(par fmt(3))) legend  keep(*fridayfestival*)

estout m1_riotnear100 m2_riotnear100 m3_riotnear100 m4_riotnear100 m5_riotnear100 using "robustness_riot100.tex", replace style(tex) varlabels(L.fridayfestival "Friday festival $ _{t-1}$") cells(b(star fmt(3)) se(par fmt(3))) legend label keep(*fridayfestival*)


*=====================================
*	Different lag lengths
*=====================================

clear

use "/Users/sv5011/Desktop/Work/Papers/Working papers/6_Do Conflict Traps Exist? Natural experimental evidence from riots in India (with Goyal)/Ethnic riots extended data/Final ethnic riots data.dta"

tsset dist year


gen dummy_1950_1955 = 0 
replace dummy_1950_1955 = 1 if year<1956 &year>1950

gen dummy_1956_1961 = 0 
replace dummy_1956_1961 = 1 if year>1955 & year<1962

gen dummy_1961_1965 = 0 
replace dummy_1961_1965 = 1 if year>1961 & year<1966

gen dummy_1966_1971 = 0 
replace dummy_1966_1971 = 1 if year>1965 & year<1972

gen dummy_1971_1975 = 0 
replace dummy_1971_1975 = 1 if year>1971 & year<1976

gen dummy_1976_1980 = 0 
replace dummy_1976_1980 = 1 if year>1975 & year<1981

gen dummy_1981_1985 = 0 
replace dummy_1981_1985 = 1 if year>1980 & year<1986

gen dummy_1986_1991 = 0 
replace dummy_1986_1991 = 1 if year>1985 & year<1992

gen dummy_1991_1995 = 0
replace dummy_1991_1995 = 1 if year>1991 & year<1996

gen dummy_1996_2001 = 0 
replace dummy_1996_2001 = 1 if year>1995 & year<2002

gen dummy_2001_2006 = 0 
replace dummy_2001_2006 = 1 if year>2001


estimates clear

ssc install coefplot, replace 

quietly: eststo m1: xtscc riot l1.fridayfestival dummy_1950_1955 dummy_1956_1961 dummy_1961_1965 dummy_1966_1971 dummy_1971_1975 dummy_1976_1980 dummy_1981_1985 dummy_1986_1991 dummy_1991_1995 dummy_1996_2001, fe 
quietly: eststo m2: xtscc riot l2.fridayfestival dummy_1950_1955 dummy_1956_1961 dummy_1961_1965 dummy_1966_1971 dummy_1971_1975 dummy_1976_1980 dummy_1981_1985 dummy_1986_1991 dummy_1991_1995 dummy_1996_2001, fe 
quietly: eststo m3: xtscc riot l3.fridayfestival dummy_1950_1955 dummy_1956_1961 dummy_1961_1965 dummy_1966_1971 dummy_1971_1975 dummy_1976_1980 dummy_1981_1985 dummy_1986_1991 dummy_1991_1995 dummy_1996_2001, fe 
quietly: eststo m4: xtscc riot l4.fridayfestival dummy_1950_1955 dummy_1956_1961 dummy_1961_1965 dummy_1966_1971 dummy_1971_1975 dummy_1976_1980 dummy_1981_1985 dummy_1986_1991 dummy_1991_1995 dummy_1996_2001, fe 
quietly: eststo m5: xtscc riot l5.fridayfestival dummy_1950_1955 dummy_1956_1961 dummy_1961_1965 dummy_1966_1971 dummy_1971_1975 dummy_1976_1980 dummy_1981_1985 dummy_1986_1991 dummy_1991_1995 dummy_1996_2001, fe 
quietly: eststo m6: xtscc riot l6.fridayfestival dummy_1950_1955 dummy_1956_1961 dummy_1961_1965 dummy_1966_1971 dummy_1971_1975 dummy_1976_1980 dummy_1981_1985 dummy_1986_1991 dummy_1991_1995 dummy_1996_2001, fe 
quietly: eststo m7: xtscc riot l7.fridayfestival dummy_1950_1955 dummy_1956_1961 dummy_1961_1965 dummy_1966_1971 dummy_1971_1975 dummy_1976_1980 dummy_1981_1985 dummy_1986_1991 dummy_1991_1995 dummy_1996_2001, fe 
quietly: eststo m8: xtscc riot l8.fridayfestival dummy_1950_1955 dummy_1956_1961 dummy_1961_1965 dummy_1966_1971 dummy_1971_1975 dummy_1976_1980 dummy_1981_1985 dummy_1986_1991 dummy_1991_1995 dummy_1996_2001, fe 
quietly: eststo m9: xtscc riot l9.fridayfestival dummy_1950_1955 dummy_1956_1961 dummy_1961_1965 dummy_1966_1971 dummy_1971_1975 dummy_1976_1980 dummy_1981_1985 dummy_1986_1991 dummy_1991_1995 dummy_1996_2001, fe 
quietly: eststo m10: xtscc riot l10.fridayfestival dummy_1950_1955 dummy_1956_1961 dummy_1961_1965 dummy_1966_1971 dummy_1971_1975 dummy_1976_1980 dummy_1981_1985 dummy_1986_1991 dummy_1991_1995 dummy_1996_2001, fe 
quietly: eststo m11: xtscc riot l11.fridayfestival dummy_1950_1955 dummy_1956_1961 dummy_1961_1965 dummy_1966_1971 dummy_1971_1975 dummy_1976_1980 dummy_1981_1985 dummy_1986_1991 dummy_1991_1995 dummy_1996_2001, fe 
quietly: eststo m12: xtscc riot l12.fridayfestival dummy_1950_1955 dummy_1956_1961 dummy_1961_1965 dummy_1966_1971 dummy_1971_1975 dummy_1976_1980 dummy_1981_1985 dummy_1986_1991 dummy_1991_1995 dummy_1996_2001, fe 
quietly: eststo m13: xtscc riot l13.fridayfestival dummy_1950_1955 dummy_1956_1961 dummy_1961_1965 dummy_1966_1971 dummy_1971_1975 dummy_1976_1980 dummy_1981_1985 dummy_1986_1991 dummy_1991_1995 dummy_1996_2001, fe 
quietly: eststo m14: xtscc riot l14.fridayfestival dummy_1950_1955 dummy_1956_1961 dummy_1961_1965 dummy_1966_1971 dummy_1971_1975 dummy_1976_1980 dummy_1981_1985 dummy_1986_1991 dummy_1991_1995 dummy_1996_2001, fe 
quietly: eststo m15: xtscc riot l15.fridayfestival dummy_1950_1955 dummy_1956_1961 dummy_1961_1965 dummy_1966_1971 dummy_1971_1975 dummy_1976_1980 dummy_1981_1985 dummy_1986_1991 dummy_1991_1995 dummy_1996_2001, fe 
quietly: eststo m16: xtscc riot l16.fridayfestival dummy_1950_1955 dummy_1956_1961 dummy_1961_1965 dummy_1966_1971 dummy_1971_1975 dummy_1976_1980 dummy_1981_1985 dummy_1986_1991 dummy_1991_1995 dummy_1996_2001, fe 
quietly: eststo m17: xtscc riot l17.fridayfestival dummy_1950_1955 dummy_1956_1961 dummy_1961_1965 dummy_1966_1971 dummy_1971_1975 dummy_1976_1980 dummy_1981_1985 dummy_1986_1991 dummy_1991_1995 dummy_1996_2001, fe 
quietly: eststo m18: xtscc riot l18.fridayfestival dummy_1950_1955 dummy_1956_1961 dummy_1961_1965 dummy_1966_1971 dummy_1971_1975 dummy_1976_1980 dummy_1981_1985 dummy_1986_1991 dummy_1991_1995 dummy_1996_2001, fe 
quietly: eststo m19: xtscc riot l19.fridayfestival dummy_1950_1955 dummy_1956_1961 dummy_1961_1965 dummy_1966_1971 dummy_1971_1975 dummy_1976_1980 dummy_1981_1985 dummy_1986_1991 dummy_1991_1995 dummy_1996_2001, fe 
quietly: eststo m20: xtscc riot l20.fridayfestival dummy_1950_1955 dummy_1956_1961 dummy_1961_1965 dummy_1966_1971 dummy_1971_1975 dummy_1976_1980 dummy_1981_1985 dummy_1986_1991 dummy_1991_1995 dummy_1996_2001, fe 


set scheme   s2mono                     
grstyle init
grstyle set plain, nogrid 

coefplot (m1 m2 m3 m4 m5 m6 m7 m8 m9 m10 ///
m11 m12 m13 m14 m15 m16 m17 m18 m19 m20, msymbol(O)), ///
levels(95) keep(*fes*) vertical yline(0, lpattern(dash) lwidth(medium thick)) ///
nokey ciopts(lwidth(*.5 *2) lcolor(gray black) ///
recast(rcap)) xlabel(, labsize(medium) )  msize(medium) ///
mlcolor(black) ylabel(, labsize(medium) ///
glstyle(solid) glcolor(bl) glwidth(vvvthin)) scale(0.8) coeflabels(l1.fridayfestival = "1" L2.fridayfestival = ///
"2" L3.fridayfestival = "3" L4.fridayfestival = "4" L5.fridayfestival = "5" L6.fridayfestival = "6" ///
 L7.fridayfestival = "7" L8.fridayfestival = "8" L9.fridayfestival = "9" ///
 L10.fridayfestival = "10" L11.fridayfestival = "11" L12.fridayfestival = "12" L13.fridayfestival = "13" ///
 L14.fridayfestival = "14" L15.fridayfestival = "15" L16.fridayfestival = "16" L17.fridayfestival = "17" ///
 L18.fridayfestival = "18" L19.fridayfestival = "19" L20.fridayfestival = "20") xtitle("Lag #", size(medium)) drop(dummy_1981_1985 dummy_1986_1991 dummy_1991_1995 dummy_1996_2001)
 
 
estout m1 m2 m3 m4 m5 m6 m7 m8 m9 m10 m11 m12 m13 m14 m15 m16 m17 m18 m19 m20, keep(*fridayfestival*)

 
** Average point estimate of first 20 lags 
display (-.0012143+.0022728+.0036993-.0080389-.008965+.0021944-.0062382-.0130249+.000836+.0065004-.0184474+.0062142+.0109876-.0051319-.007311+.0144067-.0080704-.0007532+.0084557-.0040934)/20


*=====================================
*	BJP interaction effect
*=====================================

clear
use "C:\Users\sv5011\OneDrive - Princeton University\Ethnic riots extended data\Final ethnic riots data.dta", clear

tsset dist year

estimates clear 

tsset dist year

gen dummy_1950_1955 = 0 
replace dummy_1950_1955 = 1 if year<1956 &year>1950

gen dummy_1956_1961 = 0 
replace dummy_1956_1961 = 1 if year>1955 & year<1962

gen dummy_1961_1965 = 0 
replace dummy_1961_1965 = 1 if year>1961 & year<1966

gen dummy_1966_1971 = 0 
replace dummy_1966_1971 = 1 if year>1965 & year<1972

gen dummy_1971_1975 = 0 
replace dummy_1971_1975 = 1 if year>1971 & year<1976

gen dummy_1976_1980 = 0 
replace dummy_1976_1980 = 1 if year>1975 & year<1981

gen dummy_1981_1985 = 0 
replace dummy_1981_1985 = 1 if year>1980 & year<1986

gen dummy_1986_1991 = 0 
replace dummy_1986_1991 = 1 if year>1985 & year<1992

gen dummy_1991_1995 = 0
replace dummy_1991_1995 = 1 if year>1991 & year<1996

gen dummy_1996_2001 = 0 
replace dummy_1996_2001 = 1 if year>1995 & year<2002

gen dummy_2001_2006 = 0 
replace dummy_2001_2006 = 1 if year>2001
 
gen l1_fes = l.fridayfestival

estimates clear

quietly: eststo m1: xtscc riot i.bjprule##l1_fes dummy_1976_1980 dummy_1981_1985 dummy_1986_1991 dummy_1991_1995 dummy_1996_2001, fe lag(26)

margins, dydx(l1_fes) at(bjprule=(0 1))
marginsplot, level (95)



*=====================================
*	Fixed effects for riot-prone years
*=====================================

clear

use "/Users/sv5011/Desktop/Work/Papers/Working papers/6_Do Conflict Traps Exist? Natural experimental evidence from riots in India (with Goyal)/Ethnic riots extended data/Final ethnic riots data.dta"


collapse (sum) nriot, by(year)

graph bar (mean) nriot, over(year, label(angle(90) labsize(*0.7))) ytitle("")  bar(1, fcolor(black))

clear

use "/Users/sv5011/Desktop/Work/Papers/Working papers/6_Do Conflict Traps Exist? Natural experimental evidence from riots in India (with Goyal)/Ethnic riots extended data/Final ethnic riots data.dta"

** Years with more than 50 riots nationwide:
gen riotprone_fe = 0
replace riotprone_fe = 1 if year==1986
replace riotprone_fe = 1 if year==1987
replace riotprone_fe = 1 if year==1990
replace riotprone_fe = 1 if year==1992
replace riotprone_fe = 1 if year==2002
replace riotprone_fe = 1 if year==2003
replace riotprone_fe = 1 if year==2004
replace riotprone_fe = 1 if year==2005
replace riotprone_fe = 1 if year==2006

** Main results with fixed effects for particularly riot-prone year
tsset dist year

estimates clear

** Column 1 -- Riot, fixed effects
quietly: xtscc riot l.riot riotprone_fe, fe lag(55)
quietly: estimates store m1, title(OLS)

** Column 2 -- Riot, 2sls
quietly: xi: ivreg2 riot (l.riot = l.fridayfestival) i.dist riotprone_fe, first dkraay(55) savefirst savefprefix(first1)
quietly: estimates store m2, title(2SLS)

** Column 3 -- Riot, reduced form
quietly: xtscc riot l.fridayfestival riotprone_fe, fe lag(55)
quietly: estimates store m3, title(Reduced form)

estout m1 first1* m2 m3, cells(b(star fmt(3)) se(par fmt(3))) legend label stats(N N_g widstat, fmt(%7.0f %7.0f %7.1f)) drop(*_cons* *dist_*) 

 cd "/Users/samvannoort/Desktop/Work/Papers/Working papers/9_Do Conflict Traps Exist? Natural experimental evidence from riots in India (with Goyal)/output"
estout m1 first1* m2 m3 using "riot_prone_years_fe.tex", replace style(tex) ///
varlabels(L.riot "Riot $ _{t-1}$" L.fridayfestival "Friday festival $ _{t-1}$") ///
 cells(b(star fmt(3)) se(par fmt(3))) legend label stats(widstat N N_g, fmt(%7.1f %7.0f %7.0f)) keep(*riot* *fridayfestival*) drop(*riotprone_fe*)
 
 

*=====================================
*	6 months results
*=====================================

clear

* Load data, same sample of states as I&S 2018
 use "/Users/samvannoort/Desktop/Work/Papers/Working papers/9_Do Conflict Traps Exist? Natural experimental evidence from riots in India (with Goyal)/Ethnic riots extended data/Riots_DistxMMYY.dta"

egen id = group(dist)
order id, after(dist)

gen qdate = hofd(dofm(ym(year, month_by_n)))
format %th qdate 
 
collapse (sum) riot (sum) fridayfestival (max) year, by(id qdate)

gen riot2 = 0 if riot==0
replace riot2 = 1 if riot>0

gen fridayfestival2 = 0 if fridayfestival==0
replace fridayfestival2 = 1 if fridayfestival>0

tsset id qdate
estimates clear

* exact year-dummies from 1_results(version 5) 
gen dummy_1981_1985 = 0 
replace dummy_1981_1985 = 1 if year>1980 & year<1986

gen dummy_1986_1991 = 0 
replace dummy_1986_1991 = 1 if year>1985 & year<1992

gen dummy_1991_1995 = 0
replace dummy_1991_1995 = 1 if year>1991 & year<1996

gen dummy_1996_2001 = 0 
replace dummy_1996_2001 = 1 if year>1995 & year<2002

* 5year-dummmy for 2002 to 2006 
gen dummy_2001_2006 = 0 
replace dummy_2001_2006 = 1 if year>2001

* 5year-dummies for 1950 to 1980 

gen dummy_1950_1955 = 0 
replace dummy_1950_1955 = 1 if year<1956 &year>1950

gen dummy_1956_1961 = 0 
replace dummy_1956_1961 = 1 if year>1955 & year<1962

gen dummy_1961_1965 = 0 
replace dummy_1961_1965 = 1 if year>1961 & year<1966

gen dummy_1966_1971 = 0 
replace dummy_1966_1971 = 1 if year>1965 & year<1972

gen dummy_1971_1975 = 0 
replace dummy_1971_1975 = 1 if year>1971 & year<1976

gen dummy_1976_1980 = 0 
replace dummy_1976_1980 = 1 if year>1975 & year<1981

estimates clear

** Column 1 -- Riot, fixed effects
quietly: xtscc riot l.riot dummy_1956_1961 dummy_1961_1965 dummy_1966_1971 dummy_1971_1975 dummy_1976_1980 dummy_1981_1985 dummy_1986_1991 dummy_1991_1995 dummy_1996_2001 dummy_2001_2006, fe lag(112)
quietly: estimates store m1, title(OLS)

** Column 2 -- Riot, 2sls
quietly: xi: xtivreg2 riot (l.riot = l.fridayfestival) dummy_1956_1961 dummy_1961_1965 dummy_1966_1971 dummy_1971_1975 dummy_1976_1980 dummy_1981_1985 dummy_1986_1991 dummy_1991_1995 dummy_1996_2001 dummy_2001_2006, first dkraay(112) fe savefirst savefprefix(first1)
quietly: estimates store m2, title(2SLS)

** Column 3 -- Riot, reduced form
quietly: xtscc riot l.fridayfestival dummy_1956_1961 dummy_1961_1965 dummy_1966_1971 dummy_1971_1975 dummy_1976_1980 dummy_1981_1985 dummy_1986_1991 dummy_1991_1995 dummy_1996_2001 dummy_2001_2006, fe lag(112)
quietly: estimates store m3, title(Reduced form)

estout m1 first1* m2 m3, cells(b(star fmt(3)) se(par fmt(3))) legend label stats(N N_g widstat, fmt(%7.0f %7.0f %7.1f)) drop(*_cons* *dummy*)

 cd "/Users/samvannoort/Desktop/Work/Papers/Working papers/9_Do Conflict Traps Exist? Natural experimental evidence from riots in India (with Goyal)/output"
estout m1 first1* m2 m3 using "six_months_results.tex", replace style(tex) ///
varlabels(L.riot "Riot $ _{t-1}$" L.fridayfestival "Friday festival $ _{t-1}$") ///
 cells(b(star fmt(3)) se(par fmt(3))) legend label stats(widstat N N_g, fmt(%7.1f %7.0f %7.0f)) keep(*riot* *fridayfestival*)
 
 
*=====================================
*	Deaths and duration of Friday festival induced riots
*===================================== 
 
clear

use "C:\Users\sv5011\OneDrive - Princeton University\Ethnic riots extended data\Final ethnic riots data.dta"

tsset dist year

gen dummy_1950_1955 = 0 
replace dummy_1950_1955 = 1 if year<1956 &year>1950

gen dummy_1956_1961 = 0 
replace dummy_1956_1961 = 1 if year>1955 & year<1962

gen dummy_1961_1965 = 0 
replace dummy_1961_1965 = 1 if year>1961 & year<1966

gen dummy_1966_1971 = 0 
replace dummy_1966_1971 = 1 if year>1965 & year<1972

gen dummy_1971_1975 = 0 
replace dummy_1971_1975 = 1 if year>1971 & year<1976

gen dummy_1976_1980 = 0 
replace dummy_1976_1980 = 1 if year>1975 & year<1981

gen dummy_1981_1985 = 0 
replace dummy_1981_1985 = 1 if year>1980 & year<1986

gen dummy_1986_1991 = 0 
replace dummy_1986_1991 = 1 if year>1985 & year<1992

gen dummy_1991_1995 = 0
replace dummy_1991_1995 = 1 if year>1991 & year<1996

gen dummy_1996_2001 = 0 
replace dummy_1996_2001 = 1 if year>1995 & year<2002

gen dummy_2001_2006 = 0 
replace dummy_2001_2006 = 1 if year>2001
 
estimates clear 

** Column 1 -- No. killed
quietly: xtscc KILLED c.fridayfestival##c.riot dummy_1976_1980 dummy_1981_1985 dummy_1986_1991 dummy_1991_1995 dummy_1996_2001 dummy_2001_2006, fe 
quietly: estimates store m1, title(OLS)

** Column 2 -- Natural log no. killed
gen log_killed = ln(KILLED+1)
quietly: xtscc log_killed c.fridayfestival##c.riot dummy_1976_1980 dummy_1981_1985 dummy_1986_1991 dummy_1991_1995 dummy_1996_2001 dummy_2001_2006, fe 
quietly: estimates store m2, title(OLS)

** Column 3 -- Dummy at least one person killed
gen killed_dummy = 0 if KILLED==0
replace killed_dummy = 1 if KILLED==1

quietly: xtscc killed_dummy c.fridayfestival##c.riot dummy_1976_1980 dummy_1981_1985 dummy_1986_1991 dummy_1991_1995 dummy_1996_2001 dummy_2001_2006, fe 
quietly: estimates store m3, title(OLS)

** Column 4 -- Duration in days
quietly: xtscc dur c.fridayfestival##c.riot dummy_1976_1980 dummy_1981_1985 dummy_1986_1991 dummy_1991_1995 dummy_1996_2001 dummy_2001_2006, fe 
quietly: estimates store m4, title(OLS)

** Column 5 -- Natural log duration in days
gen log_dur = ln(dur+1)

quietly: xtscc log_dur c.fridayfestival##c.riot dummy_1976_1980 dummy_1981_1985 dummy_1986_1991 dummy_1991_1995 dummy_1996_2001 dummy_2001_2006, fe 
quietly: estimates store m5, title(OLS)

** Column 6 -- Dummy at least more than one day
gen dur_dummy = 0 if dur<=1
replace dur_dummy = 1 if dur>1
 
quietly: xtscc dur_dummy dur c.fridayfestival##c.riot dummy_1976_1980 dummy_1981_1985 dummy_1986_1991 dummy_1991_1995 dummy_1996_2001 dummy_2001_2006, fe 
quietly: estimates store m6, title(OLS) 

estout m1 m2 m3 m4 m5 m6, cells(b(star fmt(3)) se(par fmt(3))) keep(*riot* *fes*) stats(N N_g, fmt(%7.0f %7.0f))


*=====================================
*	Correlation with Wilkinson and Varshney cause classification
*===================================== 

clear
use "C:\Users\sv5011\OneDrive - Princeton University\Ethnic riots extended data\Final ethnic riots data.dta", clear

drop statecode
gen str2 statecode = ""
replace statecode = "JK" if state=="jammukashmir"
replace statecode = "PU" if state=="punjab"
replace statecode = "HA" if state=="haryana"
replace statecode = "WB" if state=="westbengal"
replace statecode = "UP" if state=="uttarpradesh"
replace statecode = "TN" if state=="tamilnadu"
replace statecode = "RA" if state=="rajasthan"
replace statecode = "OR" if state=="orissa"
replace statecode = "MA" if state=="maharashtra"
replace statecode = "MP" if state=="madhyapradesh"
replace statecode = "KE" if state=="kerala"
replace statecode = "KA" if state=="karnataka"
replace statecode = "GU" if state=="gujarat"
replace statecode = "BI" if state=="bihar"
replace statecode = "AS" if state=="assam"
replace statecode = "AP" if state=="andhrapradesh"

cd "C:\Users\sv5011\OneDrive - Princeton University\Ethnic riots extended data"
save "Final ethnic riots data", replace

clear
import excel "C:\Users\sv5011\OneDrive - Princeton University\Data\FINAL_Religion_dataset_1950-2006.xls", sheet("Religion_dataset_1950-2006") firstrow clear

rename YEAR year
rename STATECODE statecode

drop if COUNTRY=="Pakistan"

merge m:m year state using "C:\Users\sv5011\OneDrive - Princeton University\Ethnic riots extended data\Final ethnic riots data.dta", force

gen festival_dummy = 0 
replace festival_dummy = 1 if REPORTED_C=="Public Rituals\Festivities (Other)"

logistic festival_dummy fridayfestival, vce(cluster dist)

*=====================================
*	Alternative specification BJP interaction
*===================================== 


clear
use "C:\Users\sv5011\OneDrive - Princeton University\Ethnic riots extended data\Final ethnic riots data.dta", clear

tsset dist year

estimates clear 

tsset dist year

gen dummy_1950_1955 = 0 
replace dummy_1950_1955 = 1 if year<1956 &year>1950

gen dummy_1956_1961 = 0 
replace dummy_1956_1961 = 1 if year>1955 & year<1962

gen dummy_1961_1965 = 0 
replace dummy_1961_1965 = 1 if year>1961 & year<1966

gen dummy_1966_1971 = 0 
replace dummy_1966_1971 = 1 if year>1965 & year<1972

gen dummy_1971_1975 = 0 
replace dummy_1971_1975 = 1 if year>1971 & year<1976

gen dummy_1976_1980 = 0 
replace dummy_1976_1980 = 1 if year>1975 & year<1981

gen dummy_1981_1985 = 0 
replace dummy_1981_1985 = 1 if year>1980 & year<1986

gen dummy_1986_1991 = 0 
replace dummy_1986_1991 = 1 if year>1985 & year<1992

gen dummy_1991_1995 = 0
replace dummy_1991_1995 = 1 if year>1991 & year<1996

gen dummy_1996_2001 = 0 
replace dummy_1996_2001 = 1 if year>1995 & year<2002

gen dummy_2001_2006 = 0 
replace dummy_2001_2006 = 1 if year>2001
 
gen l1_fes = l.fridayfestival

gen bjprule_both_period = 0 if bjprule==0
replace bjprule_both_period = 1 if bjprule==1 & l.bjprule==1

estimates clear

quietly: eststo m1: xtscc riot i.bjprule_both_period##l1_fes dummy_1976_1980 dummy_1981_1985 dummy_1986_1991 dummy_1991_1995 dummy_1996_2001, fe lag(26)

margins, dydx(l1_fes) at(bjprule_both_period=(0 1))
marginsplot, level (95)



